'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();
//物料
newModel.ItemMaster = {
    type: Schema.ObjectId,
    ref: 'ItemMaster'
};
//要货部门
newModel.DemandDepartment = {
    type: Schema.ObjectId,
    ref: 'Department'
};
//待转区
newModel.WareHouse = {
    type: Schema.ObjectId,
    ref: 'WareHouse'
};
//累计要货量
newModel.TotalDemandQty = {
    type: Number
};
//累计备货量
newModel.TotalStockQty = {
    type: Number
};
//累计已接收量
newModel.TotalReceiveQty = {
    type: Number
};
//扩展字段:
newModel.DescSeg1 = {
    type: String,
    default: '',
    trim: true
};
newModel.DescSeg2 = {
    type: String,
    default: '',
    trim: true
};

var newSchema = new Schema(newModel);
newSchema.index({ItemMaster: 1, WareHouse: 1, DemandDepartment: 1, DescSeg1: 1, DescSeg2: 1}, {"unique": true});

mongoose.model('KanbanDemand', newSchema, 'KanbanDemand');
